#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <iostream>
#include <time.h>
#include <boost/algorithm/string.hpp>
#include <boost/typeof/typeof.hpp>
#include <tr1/tuple>

#include <algorithm>

#define PRINT( x ) printf( # x ": %d\n", x )

template <typename T> T *gNew()
{
	T *p = new T;
	return p;
}

int main( int argc, char *argv[] )
{
	int *p = gNew<int>();
	*p = 3;
	PRINT( *p );
	/*
	if( int i = 1 ) {
		std::cout << "in if, i: " << i << std::endl;
	}

	union {
		uint32_t i;
		char str[4];
	};
	
	i = 1;
	if( (uint32_t) str[3] == i ) {
		std::cout << "small ending" << std::endl;
	}
	else
		std::cout << "big ending" << std::endl;
	*/

	/* <<C++ Gotcha>> p47.
	int val = 123;
	{
		int val = val;
		cout << val << endl;
	}

	const int v = 123;
	{
		enum { v = v };
		cout << v << endl;
	}
	*/

	/*
	class A
	{
	public:
		void g();
		void CallF() { f(); }
	private:
		virtual void f() { cout << "A::f()" << endl; }
	};

	class B : public A
	{
	public:
		void f() { cout << "B::f()" << endl; }
	public:
		double g;
	};

	A * p = new B;
	p->CallF();

	delete p;
	*/

	/*
	const int a = 1;
	int *p = const_cast<int*>(&a);
	*p = 2;
	cout << "value a="<< a << endl;
	cout << "value *p=" <<*p << endl;
	cout << "address a=" <<&a << endl;
	cout << "address p=" <<p << endl;
	
	const int * const k = (&a);
	cout << "value *k=" <<*k << endl;
	*/

	/*
	 * << C Traps and Pit falls >> P87
	 *
	   int c;
	   char buf[20];
	   setbuffer(stdout, buf, 20);

	   while((c=getchar())!=EOF )
		putchar(c);
	   // fflush(stdout);
	   return 0;
	 */

	/*
	   int i;
	   char c; // must be int
	   for( i = 0; i < 5; i++ ) {
		scanf("%d", c );
		printf("%d ", i);
	   }
	   printf("\n");
	   return 0;
	 */

	/*
	   int calendar[12][31];
	   int (*monthp)[31];
	   int *dayp;

	   for( monthp = calendar; monthp < &calendar[12]; monthp ++ )
		for( dayp = *monthp; dayp < &(*monthp)[31]; dayp ++ )
	 *dayp = 1;
	   PRINT(calendar[3][15]);
	   return 0;
	 */
}

